package com.interview.controller;

import com.interview.common.Result;
import com.interview.common.ResultMessage;
import com.interview.common.StatusCode;
import com.interview.entity.Examee;
import com.interview.entity.WaitingRoomInfo;
import com.interview.service.ExameeService;
import com.interview.service.WaitingRoomInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.LinkedList;
import java.util.List;

@RestController
@RequestMapping("examee")
public class ExameeController {
    @Autowired
    private ExameeService exameeService;
    @Autowired
    private WaitingRoomInfoService waitingRoomInfoService;


    @PostMapping("getExameeList")
    public Result getExameeList() {
        //获取分组信息
        WaitingRoomInfo oneWaitingRoomInfo = waitingRoomInfoService.getOneWaitingRoomInfo();
        String groupIds = oneWaitingRoomInfo.getGroupIds();
        //拆解分组
        String[] split = groupIds.split(",");
        LinkedList<String> strings = new LinkedList<>();
        for (String s : split) {
            strings.add(s);
        }
        //List<Examee> allExamee = exameeService.getAllExamee();
        List<Examee> examees=exameeService.getExameeByIds(strings);
        return new Result(true, StatusCode.OK, ResultMessage.QUERY_SUCCESS,examees);
    }
}
